package com.woniuxy.boss.bossassembly.apiimpl;


import com.woniu.api.BossApi;
import com.woniu.form.AdminForm;
import com.woniuxy.Result;
import com.woniuxy.boss.bossassembly.service.IBaAdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 后台用户表 前端控制器
 * </p>
 *
 * @author HDC
 * @since 2021-05-24
 */
@RestController
@RequestMapping("/bossassembly/ba-admin")
@Slf4j
public class BaAdminController implements BossApi {
    @Autowired
    private IBaAdminService iBaAdminService;
    @Override
    public Result addAdmin(AdminForm adminForm) {
        Integer integer = iBaAdminService.addAdmin(adminForm);
        log.info("获得id{}",integer);
        return Result.success("新增用户成功");
    }

    @Override
    public Result deleteAdmin(Integer adminId) {
        log.info("删除用户ID为{}",adminId);
        Integer integer = iBaAdminService.deleteAdmin(adminId);
        log.info("删除结果为{}",integer);
        return Result.success("删除成功");
    }

    @Override
    public Result updateAdmin(AdminForm adminForm){
        log.info("修改用户ID为{}",adminForm.getAdminId());
        iBaAdminService.updateAdmin(adminForm);
        return Result.success("修改成功");
    }

    @Override
    public Result getAllAdmin() {
        log.info("查询所有用户");
        List allAdmin = iBaAdminService.getAllAdmin();
        return Result.success(allAdmin);
    }
}

